package com.example.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2021-06-28 11:30
 */
@RestController
@RequestMapping("redirect")
public class RedirectController {





    @GetMapping("{state}")
    public String callback(HttpServletRequest request, HttpServletResponse response,@PathVariable("state")Integer state) throws IOException {
        if(state == 1) {
            response.sendRedirect("http://www.baidu.com");
        }else if (state == 2) {
            response.sendRedirect("http://www.qq.com");
        }
        return "只能输1,2";
    }


}
